<!-- include tpl=head -->
<script type="text/javascript">
function project_delete(id,title)
{
	$.dialog.confirm('{lang确定要删除此项目吗？删除会将相关内容一起删除}<br /><span class="red">'+title+'</span>',function(){
		var url = "{url ctrl=project func=delete/}&id="+id;
		$.dialog.tips('{lang正在执行删除请求…}');
		$.phpok.json(url,project_result,true);
	});
}
function project_result(rs)
{
	if(rs.status == 'ok'){
		$.dialog.alert('{lang操作成功}',function(){
			$.phpok.reload();
		});
	}else{
		$.dialog.alert(rs.content);
	}
}
function project_copy(id,title)
{
	$.dialog.confirm('{lang确定要复制此项目}<br /><span class="red">'+title+'</span>',function(){
		var url = "{url ctrl=project func=copy/}&id="+id;
		$.phpok.json(url,project_result,true);
	});
}
function set_status(id)
{
	var url = '{url ctrl=project func=status/}&id='+id;
	var old_value = $("#status_"+id).attr("value");
	var new_value = old_value == "1" ? "0" : "1";
	url += "&status="+new_value;
	$.phpok.json(url,function(rs){
		if(rs.status == 'ok'){
			$("#status_"+id).removeClass("status"+old_value).addClass("status"+new_value).attr("value",new_value);
		}else{
			$.dialog.alert(rs.content);
		}
	});
}
function update_taxis(val,id)
{
	$.ajax({
		'url':get_url('project','sort','sort['+id+']='+val),
		'dataType':'json',
		'cache':false,
		'async':true,
		'beforeSend': function (XMLHttpRequest){
			XMLHttpRequest.setRequestHeader("request_type","ajax");
		},
		'success':function(rs){
			if(rs.status == 'ok'){
				$.phpok.reload();
			}else{
				$.dialog.alert(rs.content);
				return false;
			}
		}
	});
}
$(document).ready(function(){
	$("div[name=taxis]").click(function(){
		var oldval = $(this).text();
		var id = $(this).attr('data');
		$.dialog.prompt('{lang请填写新的排序：}',function(val){
			if(val != oldval){
				update_taxis(val,id);
			}
		},oldval);
	});
});
</script>
<div class="tips">
	<div class="action"><a href="{url ctrl=project func=set/}">{lang添加项目}</a></div>
	{lang您当前的位置：}
	<a href="{echo admin_url('project')}">{lang项目管理}</a>
	&raquo; {lang项目列表}
</div>
<div class="list">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
	<th class="id">ID</th>
	<th class="w33">&nbsp;</th>
	<th class="lft">{lang项目名称}</th>
	<th class="lft">{lang标识串}</th>
	<th class="lft">{lang模块}</th>
	<th width="65">{lang排序}</th>
	<th class="lft" width="130">{lang操作}</th>
</tr>
<!-- foreach($rslist AS $key=>$value) -->
<tr>
	<td class="center gray" height="24px">{$value.id}</td>
	<td class="center"><span class="status{$value.status}" id="status_{$value.id}" onclick="set_status({$value.id})" value="{$value.status}"></span></td>
	<td><label for="id_{$value.id}">{$value.space}{$value.title}<!-- if $value.nick_title --><span class="gray i"> ({$value.nick_title})</span><!-- /if --><!-- if $value.hidden --><span class="red i">{lang（隐藏）}</span><!-- /if --></label></td>
	<td>{$value.identifier}</td>
	<td>{$value.project_module_title ? $value.project_module_title : '-'}</td>
	<td><div class="gray i hand center" title="{lang点击调整排序}" name="taxis" data="{$value.id}">{$value.taxis}</div></td>
	<td>
		<!-- if !$value.parent_id -->
		<a href="{url ctrl=project func=set pid=$value.id/}" class="ico add" title="{lang添加子项}"></a>
		<!-- else -->
		<a class="ico space"></a>
		<!-- /if -->
		<a href="{url ctrl=project func=set id=$value.id/}" class="ico edit" title="{lang编辑}"></a>
		<a href="{url ctrl=project func=content id=$value.id/}" class="ico key" title="{lang扩展}"></a>
		<a href="javascript:project_copy('{$value.id}','{$value.title}');void(0);" class="ico copy" title="{lang复制}"></a>
		<a href="javascript:project_delete('{$value.id}','{$value.title}');void(0);" class="ico delete" title="{lang删除}"></a>
	</td>
</tr>
<!-- /foreach -->
</table>
</div>
<!-- include tpl=foot -->